package com.sumainfor.pc.epc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sumainfor.common.util.CustomMap;
import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.epc.dao.MktFeign.GmfProviderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * @Author Eddy·Chen
 * @Email 835033913@qq.com
 * @Create 2019-05-17 13:58
 * 服务提供者
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class GmfProviderService {

    @Autowired
    private GmfProviderMapper mapper;

    /**
     * 查询装修  计划数、套数、成本、已付、待付
     *
     * @param miId
     * @param startTime
     * @param endTime
     * @return
     */
    public Map<String, Object> getDecoratePlanTableCount(Integer miId, String startTime, String endTime) {
        CustomMap data = CustomMap.create();
        data.put("PlanCount", mapper.getPlanCount(miId, startTime, endTime));
        data.put("HousingCount", mapper.getHousingCount(miId, startTime, endTime));
        data.put("CostSum", mapper.getPlanCost(miId, startTime, endTime, "CopeWithPrices"));
        data.put("PaidSum", mapper.getPlanCost(miId, startTime, endTime, "PaidPrices"));
        data.put("UnpaidSum", mapper.getPlanCost(miId, startTime, endTime, "UnpaidPrices"));
        return data;
    }

    /**
     * 查询子表格数据 装修计划
     *
     * @param page
     * @param miId
     * @param startTime
     * @param endTime
     * @return
     */
    public IPage<Map<String, Object>> selectPlanForSubTable(Page page, Integer miId, String startTime, String endTime) {
        return mapper.selectPlanForSubTable(page, miId, startTime, endTime);
    }

    /**
     * 查询子表格 装修套数
     *
     * @param page
     * @param miId
     * @param startTime
     * @param endTime
     * @return
     */
    public IPage<Map<String, Object>> selectHousingForSubTable(Page page, Integer miId, String startTime, String endTime) {
        return mapper.selectHousingForSubTable(page, miId, startTime, endTime);
    }

    /**
     * 查询装修 所需价格
     *
     * @param page
     * @param miId
     * @param startTime
     * @param endTime
     * @return
     */
    public IPage<Map<String, Object>> selectCostForSubTable(Page page, Integer miId, String startTime, String endTime) {
        return mapper.selectCostForSubTable(page, miId, startTime, endTime);
    }

    /**
     * 查询装修计划房源
     *
     * @param params
     * @return
     */
    public JsonResult selectPlanHousingTableForAll(Map<String, Object> params) {
        return JsonResult.success(mapper.selectPlanHousingTableForAll(params));
    }

}
